package file;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class Test08 {
    public static void main(String[] args)
    {
        File f=new File("/home/ken/Desktop/pkgUpload.js");
        FileInputStream fis=null;
        try
        {
            //因为File没有读写的能力,所以需要有个InputStream
            fis=new FileInputStream(f);
            //定义一个字节数组
            byte[] bytes=new byte[1024];
            int n=0;    //得到实际读取到的字节数
            System.out.println("/home/ken/Desktop/pkgUpload.js：");
            //循环读取
            while((n=fis.read(bytes))!=-1)
            {
                String s=new String(bytes,0,n);    //将数组中从下标0到n的内容给s
                System.out.println(s);
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            try
            {
                fis.close();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }
    }
}
